var app = getApp()
Page({

  /**
   * 页面的初始数据
   */
  data: {
    page:1,
    total_page:1,
    list:[],
    order_number:""
  },
  onSearch(e){
    this.setData({order_number:e.detail})
    this.getData({order_sn: e.detail, page: 1})
  },
  link(e){
    let id = e.currentTarget.dataset.id;
    wx.navigateTo({
      url: '/packageI/checkout-equipment/detail/detail?id='+id,
    })
  },
  /**
   * 生命周期函数--监听页面加载
   */
  onLoad: function (options) {
   
    this.getData()
  },
  async getData(json = {}) {
    app._getNetWork({
      url:app.getNetAddresss("plugin.health-check.frontend.index.index"),
      data:json,
      success:(resdata)=>{
        let { result, msg, data: { data, current_page, last_page } } = resdata.data;
        if (result == 0) {
          return app.tips(msg);
        }
        this.setData({
          page:current_page,
          total_page:last_page
        })
        if(current_page==1){
          this.setData({list:data || []})
        }else{
          this.setData({list:this.data.list.concat(data)})
        }
   
      }
    })
    
  },

  /**
   * 生命周期函数--监听页面初次渲染完成
   */
  onReady: function () {

  },

  /**
   * 生命周期函数--监听页面显示
   */
  onShow: function () {

  },

  /**
   * 生命周期函数--监听页面隐藏
   */
  onHide: function () {

  },

  /**
   * 生命周期函数--监听页面卸载
   */
  onUnload: function () {

  },

  /**
   * 页面相关事件处理函数--监听用户下拉动作
   */
  onPullDownRefresh: function () {

  },

  /**
   * 页面上拉触底事件的处理函数
   */
  onReachBottom: function () {
    if(this.data.page>=this.data.total_page){
      return
    }
    let page = this.data.page+1;
    
    let json = {
      page,
    }
    if(this.data.order_number){
      json.order_number = this.data.order_number;
    }
    this.getData(json);
  },

  /**
   * 用户点击右上角分享
   */
  onShareAppMessage: function () {

  }
})